<?php
$caption = BUtils::T('menu_preview_lbl');
$this->pageTitle = Yii::app()->name . ' - ' . $caption;

$create_dish_btn = BUtils::T('dish_create_btn');
$all_lbl = BUtils::T('all_op_lbl');
?>
<div class="container prepend-top" style="margin-bottom:.8em;">
	<?php echo CHtml::button('< ' . BUtils::T('back_btn'), array('class'=>'button', 'onclick'=>"history.go(-1)")); ?>
</div>

<div class="container prepend-top append-bottom relative">
	
	<div class="span-15">
		<div class="box_white">
			<div class="biz-form">
				<div class="margin">
					<div class="left"><h3><?php echo $caption; ?></h3></div>
					<div class="right">
<?php
if (empty($_GET['view'])) {
	echo CHtml::link('<span>'.BUtils::T('search_btn').'</span>', Yii::app()->createUrl($this->id.'/'.$this->action->id, array('view'=>'list')), array('class'=>'button button-huge button-thin button-confirm'));
} else {
	echo CHtml::link('<span>'.BUtils::T('preview_btn').'</span>', Yii::app()->createUrl($this->id.'/'.$this->action->id), array('class'=>'button button-huge button-thin button-confirm'));
}
echo '<span class="space-1"></span>' . CHtml::link("<span>{$create_dish_btn}</span>", Yii::app()->createUrl('/menu/form'), array('class'=>'button button-huge button-compliment', 'id'=>'create_new_dish', 'rel'=>'tipsy', 'title'=>BUtils::T('dish_create_eg')));
?>
					</div>
					<div class="clear"></div>
					<div class="tips"></div>
				</div>
				
				<div class="fieldswrap">
<?php
if (empty($_GET['view'])) {
} else {
	echo '<div class="fields mobile" style="text-align:right;">';
	echo CHtml::form(Yii::app()->createUrl($this->id.'/'.$this->action->id, array('view'=>'list')), 'post');
	echo CHtml::textField('filter_name', '') . '<span class="space-1"></span>';
	echo CHtml::dropDownList('filter_status', '', BUtils::DishStatus(), array('empty'=>$all_lbl)) . '<span class="space-1"></span>';
	echo CHtml::ajaxSubmitButton(BUtils::T('search_btn'), null, array('beforeSend'=>'beforeSend', 'success'=>'success'), array('class'=>'button button-huge button-confirm'));
	echo CHtml::endForm();
	echo '<br />';
	echo '<div style="text-align:right;">';
	$this->widget('CLinkPager', array(
		'currentPage' => $pages->getCurrentPage(),
		'itemCount' => $pages->getItemCount(),
		'pageSize' => $pages->getPageSize(),
		'prevPageLabel' => '&lt;',
		'nextPageLabel' => '&gt;',
		'firstPageLabel' => '&lt;&lt;',
		'lastPageLabel' => '&gt;&gt;',
		'maxButtonCount' => 5,
		'header' => '',
		'footer' => '',
		'htmlOptions' => array('class'=>'pagination'),
	));
	echo '</div>';
	echo '</div>';
}
?>
					<div>
						<div id="loading-bar" style="text-align:center; margin:20px 0;">
							<img src="<?php echo Yii::app()->baseUrl; ?>/images/loader-bar.gif" />
						</div>
<div class="menu-table" id="item-list">

</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div class="span-9 right last" id="sticky-right">
		<div class="box_white append-bottom">
			<div class="biz-form margin">
				<h3><?php echo BUtils::T('dish_preview_lbl'); ?></h3>
				<div class="tips"><?php echo BUtils::T('menu_how_it_works_eg'); ?></div>
				<div id="menuItem-preview" style="text-align:center;">
				</div>
			</div>
		</div>
		<?php BHelper::HtmlCompletionTips(); ?>
	</div>
	
</div>
<script type="text/javascript">
$(function() {
	//set the preview box as sticky style.
	$('#sticky-right').stickyfloat({duration:0});
	
	// loading the list
	ajaxPages(location.href);
});
function beforeSend() {
	$("#loading-bar").show();
	$("#item-list").html('');
}
function success(html) {
	$("#loading-bar").hide();
	$("#item-list").html(html);
}

function ajaxPages(url) {
	jQuery.ajax({
		'type':'POST',
		'url':url,
		'cache':false,
		'data':jQuery(this).parents("form").serialize(),
		'beforeSend':beforeSend,
		'success':success
	});
}

</script>